<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <input type="text" id="msg" />
    <button id="btn">发送消息</button>
    <!-- <script src="https://cdn.socket.io/3.0.0/socket.io.js"></script> -->
    <!-- 从node_modules里面找的 -->

    <script src="/socket.io/socket.io.js"></script>
    <script>
      var socket = io()
      document.getElementById('btn').addEventListener('click', function () {
        var value = document.getElementById('msg').value
        socket.emit('chat msg', value)
        document.getElementById('msg').value = ''
      })
    </script>
  </body>
</html>
